<template>
  <el-radio-group class="xt-radio">
    <el-radio
      v-for="{ i18n, ...op } in options"
      :key="op[alias.code]"
      :value="op[alias.code]"
      v-bind="op"
      >{{ setI18n(i18n, op[alias.name]) }}</el-radio
    >
  </el-radio-group>
</template>

<script lang="ts">
export default {
  name: "xt-radio",
};
</script>

<script setup lang="ts">
import { OptionType, AliasType } from "@/typings";
import { useLocalI18n } from "@/locales/i18n";
const { setI18n } = useLocalI18n();

interface PropType {
  [propName: string]: any;
  options: OptionType[];
  alias?: AliasType;
}

withDefaults(defineProps<PropType>(), {
  options: () => [],
  alias: () => ({
    name: "name",
    code: "code",
  }),
});
</script>
